﻿using System;
using System.Drawing;
using System.Windows.Forms;

using ProfileManager.DataAccess;

namespace ProfileManager.Controls
{
    public partial class ServiceTypeBox : UserControl
    {
        #region properties

        public ServiceType ServiceTypeValue { get; set; }

        #endregion

        public ServiceTypeBox()
        {

        }

        public ServiceTypeBox(ServiceType serviceType)
        {
            InitializeComponent();
            
            ServiceTypeValue = serviceType;

            lServiceTypeName.Text = serviceType.Name;
            pbServiceTypeLogo.Image = serviceType.IconImage ?? pbServiceTypeLogo.Image;
        }
    }

    public class ServiceTypeBoxCreator : ServiceAccountItem<ServiceTypeBox>
    {
        #region IListViewItemCustom<LabelAntiAliasControl> Members

        public override void Clear(ServiceTypeBox item)
        {
            item.Tag = null;
        }

        public override void Add(ServiceTypeBox itemPlaceholder, ServiceTypeBox itemNew, EventHandler eventHandler)
        {
            itemPlaceholder.ForeColor = itemNew.ForeColor;
            itemPlaceholder.Tag = itemNew.Tag;
            itemPlaceholder.ServiceTypeValue = itemNew.ServiceTypeValue;
            AddEvents(itemPlaceholder, eventHandler);
        }

        public override void Copy(ServiceTypeBox itemTarget, ServiceTypeBox itemSource)
        {
            itemTarget.ForeColor = itemSource.ForeColor;
            itemTarget.Tag = itemSource.Tag;
            itemTarget.ServiceTypeValue = itemSource.ServiceTypeValue;
        }

        public override ServiceTypeBox Create(int index)
        {
            ServiceTypeBox result = new ServiceTypeBox
            {
                Name = string.Format("Item{0}", index),
                Left = 0,
                Height = 15
            };
            result.Top = index * (result.Height + result.Margin.Top + result.Margin.Bottom) + result.Margin.Top;
            return result;
        }

        public override void AddEvents(ServiceTypeBox item, EventHandler eventHandler)
        {

        }

        #endregion
    }
}
